package com.xvyy.tingshu.order.adapter.impl;

import com.xvyy.tingshu.common.constant.SystemConstant;
import com.xvyy.tingshu.common.rabbit.constant.MqConst;
import com.xvyy.tingshu.common.rabbit.service.RabbitService;
import com.xvyy.tingshu.order.adapter.PayWay;
import com.xvyy.tingshu.order.service.OrderInfoService;
import com.xvyy.tingshu.vo.order.OrderInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * ClassName: WxPay
 * Package: com.xvyy.tingshu.order.adapter
 *
 * @Description: 微信支付适配器
 * @Author: xvyy
 * @Create: 2025/2/11 - 11:07
 * @Version: v1.0
 */
@Component
public class WxPayImpl implements PayWay {

    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private RabbitService rabbitService;

    @Override
    public Boolean supportPayWay(String payWay) {
        return SystemConstant.ORDER_PAY_WAY_WEIXIN.equals(payWay);
    }

    @Override
    public void payWay(OrderInfoVo orderInfoVo, String orderNo, Long userId) {
        //TODO 微信支付的实现逻辑
        System.out.println("微信支付");
        // 保存订单信息
        orderInfoService.saveOrderInfo(orderNo, orderInfoVo, userId);
        // 向延迟队列发送消息，让该延迟队列在，进行订单过期处理
        rabbitService.sendDealyMessage(MqConst.EXCHANGE_CANCEL_ORDER, MqConst.ROUTING_CANCEL_ORDER, orderNo,
                60);
//                MqConst.CANCEL_ORDER_DELAY_TIME);
    }
}
